import Login from '@/views/login/Login'
import Welcome from '@/views/welcome'
import Error404 from '@/views/404'
import { createBrowserRouter, Navigate, type RouteObject } from 'react-router-dom'
import Error403 from '@/views/403'
import Layout from '@/layout'
import Dashboard from '@/views/dashboard'
import UserList from '@/views/system/user'
import DeptList from '@/views/system/dept'
import MenuList from '@/views/system/menu'
import AuthLoader from './AuthLoader'
import RoleList from '@/views/system/role'
import OrderList from '@/views/system/order/orderList'
import Cluster from '@/views/system/order/cluster'
import DriverList from '@/views/system/order/diriverList'

export const router = [
  {
    path: '/',
    element: <Navigate to='/welcome' />
  },
  {
    path: '/login',
    element: <Login />
  },
  {
    element: <Layout />,
    loader: AuthLoader,
    id: 'layout',
    children: [
      {
        path: '/welcome',
        element: <Welcome />
      },
      {
        path: '/dashboard',
        element: <Dashboard />
      },
      {
        path: '/userList',
        element: <UserList />
      },
      {
        path: '/deptList',
        element: <DeptList />
      },
      {
        path: '/menuList',
        element: <MenuList />
      },
      {
        path: '/roleList',
        element: <RoleList />
      },
      {
        path: '/orderList',
        element: <OrderList />
      },
      {
        path: '/cluster',
        element: <Cluster />
      },
      {
        path: '/driverList',
        element: <DriverList />
      }
    ]
  },
  {
    path: '*',
    element: <Navigate to='/404' />
  },
  {
    path: '/404',
    element: <Error404 />
  },
  {
    path: '/403',
    element: <Error403 />
  }
]
// api路由
// eslint-disable-next-line react-refresh/only-export-components
export default createBrowserRouter(router)

// 组件路由
// export default function Router() {
//   return useRoutes(router)
// }
